package com.sea.physical.service.impl;

import com.sea.physical.entity.Freight;
import com.sea.physical.entity.FreightRecord;
import com.sea.physical.mapper.FreightMapper;
import com.sea.physical.service.FreightRecordService;
import com.sea.physical.service.FreightService;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import java.io.InputStream;
import java.util.HashMap;
import java.util.List;

@Service
public class FreightServiceImpl implements FreightService
{
    @Autowired
    private FreightMapper freightMapper;
    @Autowired
    private FreightRecordService freightRecordService;

    @Override
    public List<Freight> findByCnd(Freight freight) {
        return freightMapper.findByCnd(freight);
    }

    @Override
    public int save(Freight freight) {
        return freightMapper.insert(freight);
    }

    @Override
    public int delete(Integer id) {
        return freightMapper.delete(id);
    }

    @Override
    public Freight findById(Integer id) {
        return freightMapper.findById(id);
    }

    @Override
    public int usave(Freight freight) {
        FreightRecord record=new FreightRecord();
        record.setFreightId(freight.getId());
        record.setFreightTotal(freight.getFreightTotal());
        freightRecordService.save(record);
        return freightMapper.update(freight);
    }

    @Override
    public Freight findFreight(Freight freight) {
        return freightMapper.findFreight(freight);
    }

}
